@echo off

echo Starting Blind Box Application with all dependencies...

REM 设置基础类路径
set CLASSPATH=target\classes

REM 查找Maven本地仓库
set MAVEN_REPO=%USERPROFILE%\.m2\repository

REM 查找Spring Boot相关依赖
if exist "%MAVEN_REPO%\org\springframework\boot" (
    echo Adding Spring Boot dependencies...
    for /r "%MAVEN_REPO%\org\springframework\boot" %%j in (*.jar) do (
        set CLASSPATH=!CLASSPATH!;%%j
    )
)

REM 查找Spring相关依赖
if exist "%MAVEN_REPO%\org\springframework" (
    echo Adding Spring dependencies...
    for /r "%MAVEN_REPO%\org\springframework" %%j in (*.jar) do (
        set CLASSPATH=!CLASSPATH!;%%j
    )
)

REM 查找其他常见依赖
if exist "%MAVEN_REPO%\com\fasterxml\jackson" (
    echo Adding Jackson dependencies...
    for /r "%MAVEN_REPO%\com\fasterxml\jackson" %%j in (*.jar) do (
        set CLASSPATH=!CLASSPATH!;%%j
    )
)

if exist "%MAVEN_REPO%\org\springdoc" (
    echo Adding SpringDoc dependencies...
    for /r "%MAVEN_REPO%\org\springdoc" %%j in (*.jar) do (
        set CLASSPATH=!CLASSPATH!;%%j
    )
)

REM 尝试运行应用程序
echo Running application with classpath: !CLASSPATH!
java -cp "!CLASSPATH!" com.downbox.BlindBoxApplication